package util
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.geom.Matrix;

	public class RhBitmapUtil
	{
		public function RhBitmapUtil()
		{
		}
		
		static public  function resizeBitmap(source:BitmapData, width:Number, height:Number):Bitmap//BitmapData
		{
			var scaleX:Number = width/source.width;
			var scaleY:Number = height/source.height;
			
			var bitmapData:BitmapData;
			bitmapData = source;
			
			bitmapData = new BitmapData(Math.ceil(source.width * scaleX), Math.ceil(source.height * scaleY), true, 0);
			bitmapData.draw(source, new Matrix(scaleX, 0, 0, scaleY), null, null, null, true);
			//return bitmapData;
			return new Bitmap(bitmapData);
		}
		
		static public  function resizeBitmapScale(source:BitmapData, scale:Number):Bitmap//BitmapData
		{
			
			var bitmapData:BitmapData;
			bitmapData = source;
			
			bitmapData = new BitmapData(Math.ceil(source.width * scale), Math.ceil(source.height * scale), true, 0);
			bitmapData.draw(source, new Matrix(scale, 0, 0, scale), null, null, null, true);
			//return bitmapData;
			return new Bitmap(bitmapData);
		}
	}
}